package n1163;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	static int dp[]=new int[101];
	
	static int a[]=new int[101];
	
	static int N,max;
	
	static void solve(int k)
	{
		for(int i=k-1;i>=0;i--)
		{
			if(i>0)dp[i]=a[i]+Math.max(dp[i], dp[i-1]);
			else dp[i]=a[i]+dp[i];
			if(dp[i]>max)max=dp[i];
		}
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		Scanner cin=new Scanner(bf);
		N=cin.nextInt();
		for(int i=1;i<=N;i++)
		{
			for(int j=0;j<i;j++)
			{
				a[j]=cin.nextInt();
			}
			solve(i);
		}
		System.out.println(max);
	}

}
